package pacman.entries.pacman.meta_graph.features;

import java.util.HashSet;

import pacman.entries.pacman.meta_graph.IMetaGraphFeature;
import pacman.entries.pacman.meta_graph.IMetaGraphObject;
import pacman.entries.pacman.meta_graph.MetaGraphNode;
import pacman.game.Game;
import pacman.game.Constants.DM;

public class NodeFeatureNumPills implements IMetaGraphFeature {
	
	@Override
	public float Evaluate(IMetaGraphObject object, Game game) {
		
		// TODO should cache results of these operations
		
		MetaGraphNode node = (MetaGraphNode)object;
		int index = game.getPacmanCurrentNodeIndex();
		
		if (index == node.MazeIndex())
			return 0;
		
		int count = 0;
		
		int[] path = game.getShortestPath(index, node.MazeIndex());
		for (int step : path) {
			int pillIndex = game.getPillIndex(step);
			if (pillIndex > -1 && game.isPillStillAvailable(pillIndex))
				count++;
		}
		
		return count;
	}

}
